package com.wtc.view;

import com.wtc.service.EmployeeService;
import com.wtc.utils.Utility;

import java.io.IOException;

public class MybatisDemoTest {
    private boolean loop = true;
    private char key = ' ';
    public void mainMenu() throws IOException{
        //创建对象，用来调用增删改查方法
        EmployeeService employeeService = new EmployeeService();
        //循环菜单
        do {
            //功能菜单显示
            System.out.println("————————功能列表————————");
            System.out.println("0、退出");
            System.out.println("1、查询");
            System.out.println("2、添加");
            System.out.println("3、修改");
            System.out.println("4、删除");
            //用来接收功能选择
            System.out.print("输入相应功能序号：");
            key = Utility.readChar();
            switch (key) {
                case '0':
                    //退出
                    loop = false;
                    break;
                case '1':
                    //查询
                    employeeService.select();
                    System.out.println("显示完毕！");
                    break;
                case '2':
                    //添加
                    employeeService.insert();
                    break;
                case '3':
                    //修改
                    employeeService.update();
                    break;
                case '4':
                    //删除
                    employeeService.delete();
                    break;
            }
        } while (loop);
    }

}
